package com.csvreader;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Timestamp;

public class TestExits {

	public static void main(String[] args) throws Exception {  
        initData();  
    }  
      
    public static void initData() throws Exception {  
        //DriverManager.registerDriver(new Mys); 
    	// 驱动程序名
        String driver = "com.mysql.jdbc.Driver";
        Connection conn = null;  
        try {  
        	// 加载驱动程序
            Class.forName(driver);
            String url = "jdbc:mysql://192.168.0.200:3306/caiji";  
            String username = "root";  
            String password = "123456";  
            conn = DriverManager.getConnection(url, username, password);  
            conn.setAutoCommit(false);  
              
            //conn.createStatement().execute("truncate table base_customer");  
              
//            PreparedStatement psst = conn.prepareStatement("insert into base_customer values(?,?,?,?,?,?,?,?)");  
//  
//            for(int i=1; i<=1000010;i++) {//100w  
//                int count = 1;  
//                psst.setInt(count++, i);  
//                psst.setString(count++, "user" + i);  
//                psst.setString(count++, "user" + i);  
//                psst.setString(count++, "user" + i);  
//                psst.setString(count++, "user" + i);  
//                psst.setString(count++, "user" + i);  
//                psst.setTimestamp(count++, new Timestamp(System.currentTimeMillis()));  
//                psst.setString(count++, "key" + i);  
//                
//                psst.addBatch();  
//                if(i%10000==0) {
//                psst.executeBatch();
//                conn.commit();
//                }
//            }  
              
            PreparedStatement psst2 = conn.prepareStatement("insert into base_customer_sign values(?,?,?,?,?,?)");  
  
            for(int i=1; i<=10000;i++) {//100  
                int count = 1;  
                psst2.setInt(count++, i);  
                psst2.setInt(count++, i);  
                psst2.setTimestamp(count++, new Timestamp(System.currentTimeMillis()));  
                psst2.setInt(count++, 1);  
                psst2.setInt(count++, 1);  
                psst2.setInt(count++, i);
                psst2.addBatch();  
                psst2.executeBatch();  
                conn.commit();  
            }  
              
            psst2.close();  
            conn.commit();  
        } catch (Exception e) {  
            e.printStackTrace();  
            conn.rollback();  
              
        } finally {  
            conn.close();  
        }  
    }

}
